﻿using LogLib;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EECMISWS
{
    public class WebClientConfig
    {
        /// <summary>
        /// 客户端填表单位编号
        /// </summary>
        private string _client_dwbh = "";
        public string TBDWBH
        {
            get { return _client_dwbh; }
            set { _client_dwbh = value; }
        }

        /// <summary>
        /// 客户端IP
        /// </summary>
        private string _client_ip = "192.0.0.1";
        public string Client_IP
        {
            get { return _client_ip; }
            set { _client_ip = value; }
        }

        /// <summary>
        /// 客户端证书编号
        /// </summary>
        private string _client_zsbh = "192.0.0.1";
        public string Client_ZSBH
        {
            get { return _client_zsbh; }
            set { _client_zsbh = value; }
        }

        /// <summary>
        /// 单位名称
        /// </summary>
        private string _client_dwmc = "";
        public string Client_DWMC
        {
            get { return _client_dwmc; }
            set { _client_dwmc = value; }
        }

        /// <summary>
        /// 单位代理人姓名
        /// </summary>
        private string _client_xm = "出入境";
        public string Client_XM
        {
            get { return _client_xm; }
            set { _client_xm = value; }
        }

        /// <summary>
        /// 单位代理人身份证号
        /// </summary>
        private string _client_sfzh = "出入境";
        public string Client_SFZH
        {
            get { return _client_sfzh; }
            set { _client_sfzh = value; }
        }

        /// <summary>
        /// 地区行政区划
        /// </summary>
        private string _cityCode = "";
        public string CityCode
        {
            get { return _cityCode; }
            set { _cityCode = value; }
        }

        public WebClientConfig()
        {
            //Load();
        }

        public void Load()
        {
            _client_dwbh = WebSetting.LoadStringValue("TBDWBH");
            _client_ip = WebSetting.LoadStringValue("IP");
            _client_dwmc = WebSetting.LoadStringValue("DWMC");
            _client_zsbh = WebSetting.LoadStringValue("ZSBH");
            _client_xm = WebSetting.LoadStringValue("XM");
            _client_sfzh = WebSetting.LoadStringValue("SFZH");
            _cityCode = WebSetting.LoadStringValue("CityCode");
            Log.WriteAsync("CityCode: " + CityCode);
            Log.WriteAsync("填表单位编号: " + TBDWBH);
        }

        public void Save()
        {
            WebSetting.WriteValue("ClientConfig", "TBDWBH", _client_dwbh);
            WebSetting.WriteValue("ClientConfig", "IP", _client_ip);
            WebSetting.WriteValue("ClientConfig", "DWMC", _client_dwmc);
            WebSetting.WriteValue("ClientConfig", "ZSBH", _client_zsbh);
            WebSetting.WriteValue("ClientConfig", "XM", _client_xm);
            WebSetting.WriteValue("ClientConfig", "SFZH", _client_sfzh);
            WebSetting.WriteValue("ClientConfig", "CityCode", _cityCode);
        }
    }
}
